<!DOCTYPE html>
<html lang="en">
<include file="CommonSidebar:common-head"/>
<link rel="stylesheet" href="__ROOT__/Application/Admin/Public/css/common.css">
<link href="__ROOT__/Application/Admin/Public/css/jquery.datetimepicker.css" rel="stylesheet">
<link href="__PUBLIC__/Admin/css/bootstrap-datetimepicker.css" rel="stylesheet">
<body>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-md-12">
                <h1 class="page-header">所有不知道要不要的书籍</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                    <div class="panel panel-default">
                        <div class="panel-heading" role="tab" id="headingOne">
                            <h4 class="panel-title">
                                <a role="button" data-toggle="collapse" data-parent="#accordion"
                                   href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                    搜索栏
                                </a>
                            </h4>
                        </div>
                        <div id="collapseOne" class="panel-collapse collapse" role="tabpanel"
                             aria-labelledby="headingOne">
                            <div class="panel-body">
                                <form action="{:U('Index')}" class="form-horizontal" method="get">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">书籍名称</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="TITLE" value="{$CSDATA.TITLE}">
                                        </div>
                                        <label class="col-sm-2 control-label">条形码</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="ISBN" value="{$CSDATA.ISBN}">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">作者名称</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="AUTHOR" value="{$CSDATA.AUTHOR}">
                                        </div>
                                        <label class="col-sm-2 control-label">出版社</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="PRESS" value="{$CSDATA.PRESS}">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">书籍包装</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="PACKING_SPECIFICATION">
                                                <option value="">ALL</option>
                                                <foreach name="BOOK_BZ" item="v" key="k">
                                                    <option value="{$v.region_name}">{$v.region_name}</option>
                                                </foreach>
                                            </select>
                                        </div>
                                    </div>


                                    <input class="form-control" type="hidden" name="SGCODE" value="{$SGCODE}">

                                    <div class="form-group">
                                        <div class="col-sm-10 col-sm-offset-2">
                                            <button type="submit" class="btn  btn-primary">筛选</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">

                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <div class="dataTable_wrapper">
                            <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <include file="Extends/searchForUser"/>
                                <thead>
                                <tr>
                                    <th style="text-align:center"><input name="all_checkbox" type='checkbox'
                                                                         id="all_checkbox"></th>
                                    <th class="text-center GridSortTh" width="11%" data-order="ISBN">条形码</th>
                                    <th class="text-center GridSortTh" style="text-align:center" data-order="PIC_URL">
                                        书籍图片
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="TITLE"
                                        width="250px">书名
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="AUTHOR">
                                        作者
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="PRESS">
                                        出版社
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh"
                                        data-order="PACKING_SPECIFICATION">书籍包装
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="Y_PRICE">
                                        定价
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="SM_TIME">
                                        扫码时间
                                    </th>
                                    <th style="text-align:center" width="10%" class="text-center GridSortTh"
                                        data-order="OPENID">扫码用户
                                    </th>
                                    <th style="text-align:center" width="10%">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <foreach name="data" item="v">
                                    <if condition="$v.IS_BLACK == 1">
                                        <tr style="color: silver">
                                            <else/>
                                        <tr>
                                    </if>
                                    <td><input type='checkbox' name='checkbox'></td>
                                    <td><a target='_blank' href="{:U('Book/index')}?ISBN={$v.ISBN}">
                                        <span class="text-danger">{$v.ISBN}</span></a><br/>
                                        <a target='_blank'
                                           href="http://search.dangdang.com?key={$v.ISBN}&filter=0%7C0%7C0%7C0%7C0%7C1%7C0%7C0%7C0%7C0%7C0%7C0%7C0%7C#J_tab">
                                            <span class="text">{$v.ISBN}</span></a>
                                    </td>
                                    <td><img width="80px" src="{$v.PIC_URL}"></td>
                                    <td>{$v.TITLE}</td>
                                    <td>{$v.AUTHOR}</td>
                                    <td>{$v.PRESS}</td>
                                    <td>{$v.PACKING_SPECIFICATION}</td>
                                    <td>{$v.Y_PRICE}</td>
                                    <td>{$v.SM_TIME}</td>
                                    <td><a target="_blank" href="{:U('User/Index')}?user_id={$v.OPENID}"> <span
                                            class="text-danger">{$v.user_wx_name}</span></a></td>

                                    <td>
                                        <if condition="$v.IS_BLACK == 1">
                                            <a target='_blank' ><span style="color: black"
                                                    class="btn btn-warning btn-xs">黑名单</span></a><br/>
                                            <else/>
                                            <a target='_blank' href="{:U('EditBookIndex')}?ID={$v.ID}"><span
                                                    class="btn btn-warning btn-xs">编辑/查看</span></a><br/>
                                        </if>
                                        <span class="btn btn-danger btn-xs"
                                              onclick='del("{$v.ID}",$(this))'>删除</span><br/>

                                        <if condition="$v.TITLE != null && $v.PIC_URL != null  && $v.PIC_URL !='' ">
                                            <span class="btn btn-danger btn-xs" onclick='AddBook("{$v.ID}",$(this),0)'>加入主库</span><br/>
                                            <span class="btn btn-warning btn-xs" onclick='AddBook("{$v.ID}",$(this),1)'>加入黑名单</span>
                                        </if>
                                    </td>

                                    </tr>
                                </foreach>
                                </tbody>
                            </table>
                            <div class="blue">{$show}</div>
                        </div>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
    </div>
    <!-- /#page-wrapper -->
</div>
<include file="CommonSidebar:common-script"/>
<script src="__PUBLIC__/Admin/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="__PUBLIC__/Admin/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
<script src="__PUBLIC__/Common/grid.js"></script>
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
<script type="text/javascript">
    $('#dataTables-example').grid();
</script>
<script>
    //加入主库
    function AddBook(ID, $elem, top) {
        if (confirm("确认操作？")) {
            $.post("{:U('AddBook')}",
                    {ID: ID, TOP: top},
                    function (data) {
                        if (parseInt(data) > 0) {
                            $elem.parent().parent().remove();
                            alert('加入成功');
                        } else {
                            alert('加入失败');
                        }
                    });
        }
    }

    //    排序
    function sort(elem) {
        var sortNAME = elem.attr("name");
        var isDESC = elem.attr("data-type");
        if (isDESC) {
            if (isDESC == 'DESC') {
                isDESC = 'ASC'
            } else {
                isDESC = 'DESC'
            }
        } else {
            isDESC = 'DESC'
        }
        location.href = "{:U('Index')}?sortNAME=" + sortNAME + "&isDESC=" + isDESC;
        //location.href实现客户端页面的跳转
    }
    //    显示操作
    function showcz(elem) {
        if (elem.next().next().is(":hidden")) {
            elem.next().next().show();    //如果元素为隐藏,则将它显现
        } else {
            elem.next().next().hide();     //如果元素为显现,则将其隐藏
        }
    }


    <!--全选择框-->
    $("#all_checkbox").click(function () {
        if ($(this).is(':checked')) {
            $("input[name='checkbox']").prop("checked", "true");
        } else {
            $("input[name='checkbox']").removeAttr("checked", false);

        }
    });
    //删除
    function del(ID, $elem) {
        if (confirm("确认删除？")) {
            $.post("{:U('delete')}",
                    {ID: ID},
                    function (data) {
                        if (parseInt(data) == 1) {
                            $elem.parent().parent().remove();
                            alert('删除成功');
                        } else {
                            alert('删除失败');
                        }
                    });
        }
    }


</script>
</body>
</html>
